package com.empire.module.spider.controller.app.lotteryfootballgamezucaittg;

import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;

import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;

import javax.validation.constraints.*;
import javax.validation.*;
import javax.servlet.http.*;
import java.util.*;
import java.io.IOException;

import com.empire.framework.common.pojo.PageParam;
import com.empire.framework.common.pojo.PageResult;
import com.empire.framework.common.pojo.CommonResult;
import com.empire.framework.common.util.object.BeanUtils;
import static com.empire.framework.common.pojo.CommonResult.success;

import com.empire.framework.excel.core.util.ExcelUtils;

import com.empire.framework.apilog.core.annotation.ApiAccessLog;
import static com.empire.framework.apilog.core.enums.OperateTypeEnum.*;

import com.empire.module.spider.controller.app.lotteryfootballgamezucaittg.vo.*;
import com.empire.module.spider.dal.dataobject.lotteryfootballgamezucaittg.LotteryFootballGameZucaiTtgDO;
import com.empire.module.spider.service.lotteryfootballgamezucaittg.LotteryFootballGameZucaiTtgService;

@Tag(name = "用户 APP - 足彩4场总进球游戏")
@RestController
@RequestMapping("/spider/lottery-football-game-zucai-ttg")
@Validated
public class AppLotteryFootballGameZucaiTtgController {

    @Resource
    private LotteryFootballGameZucaiTtgService lotteryFootballGameZucaiTtgService;

    @PostMapping("/create")
    @Operation(summary = "创建足彩4场总进球游戏")
    public CommonResult<String> createLotteryFootballGameZucaiTtg(@Valid @RequestBody AppLotteryFootballGameZucaiTtgSaveReqVO createReqVO) {
        return success(lotteryFootballGameZucaiTtgService.createLotteryFootballGameZucaiTtg(createReqVO));
    }

    @PutMapping("/update")
    @Operation(summary = "更新足彩4场总进球游戏")
    public CommonResult<Boolean> updateLotteryFootballGameZucaiTtg(@Valid @RequestBody AppLotteryFootballGameZucaiTtgSaveReqVO updateReqVO) {
        lotteryFootballGameZucaiTtgService.updateLotteryFootballGameZucaiTtg(updateReqVO);
        return success(true);
    }

    @DeleteMapping("/delete")
    @Operation(summary = "删除足彩4场总进球游戏")
    @Parameter(name = "id", description = "编号", required = true)
    public CommonResult<Boolean> deleteLotteryFootballGameZucaiTtg(@RequestParam("id") String id) {
        lotteryFootballGameZucaiTtgService.deleteLotteryFootballGameZucaiTtg(id);
        return success(true);
    }

    @GetMapping("/get")
    @Operation(summary = "获得足彩4场总进球游戏")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    public CommonResult<AppLotteryFootballGameZucaiTtgRespVO> getLotteryFootballGameZucaiTtg(@RequestParam("id") String id) {
        LotteryFootballGameZucaiTtgDO lotteryFootballGameZucaiTtg = lotteryFootballGameZucaiTtgService.getLotteryFootballGameZucaiTtg(id);
        return success(BeanUtils.toBean(lotteryFootballGameZucaiTtg, AppLotteryFootballGameZucaiTtgRespVO.class));
    }

    @GetMapping("/page")
    @Operation(summary = "获得足彩4场总进球游戏分页")
    public CommonResult<PageResult<AppLotteryFootballGameZucaiTtgRespVO>> getLotteryFootballGameZucaiTtgPage(@Valid AppLotteryFootballGameZucaiTtgPageReqVO pageReqVO) {
        PageResult<LotteryFootballGameZucaiTtgDO> pageResult = lotteryFootballGameZucaiTtgService.getLotteryFootballGameZucaiTtgPage(pageReqVO);
        return success(BeanUtils.toBean(pageResult, AppLotteryFootballGameZucaiTtgRespVO.class));
    }

    @GetMapping("/export-excel")
    @Operation(summary = "导出足彩4场总进球游戏 Excel")
    @ApiAccessLog(operateType = EXPORT)
    public void exportLotteryFootballGameZucaiTtgExcel(@Valid AppLotteryFootballGameZucaiTtgPageReqVO pageReqVO,
              HttpServletResponse response) throws IOException {
        pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
        List<LotteryFootballGameZucaiTtgDO> list = lotteryFootballGameZucaiTtgService.getLotteryFootballGameZucaiTtgPage(pageReqVO).getList();
        // 导出 Excel
        ExcelUtils.write(response, "足彩4场总进球游戏.xls", "数据", AppLotteryFootballGameZucaiTtgRespVO.class,
                        BeanUtils.toBean(list, AppLotteryFootballGameZucaiTtgRespVO.class));
    }

}
